using System;
using System.Linq;
using NUnit.Framework;

namespace TDDGettingStarted.DomainLayer.Repositories
{
   public interface IInventoryRepository
   {
      InventoryWeek GetInventoryWeek(int facilityNumber, DateTime weekEndDate);
   }

   public class InventoryRepositoryStub : IInventoryRepository
   {
      public InventoryWeek GetInventoryWeek(int facilityNumber, DateTime weekEndDate)
      {
         var inventoryWeek = new InventoryWeek
                       {
                          FacilityNumber = facilityNumber,
                          WeekEndDate = weekEndDate
                       };

         //inventoryWeek.AddInventory(...);

         return inventoryWeek;
      }
   }


   namespace InventoryRepositoryDesignSpace
   {
      [TestFixture]
      public class RetrievingInventoryWeeks
      {
         private int _facilityNumber = -99;
         private DateTime _weekEndDate = DateTime.Today;

         [Test]
         public void GetInventoryWeekTest()
         {
            InventoryWeek inventoryWeek =
               CreateSUT().GetInventoryWeek(_facilityNumber, _weekEndDate);

            Assert.IsNotNull(inventoryWeek);
            Assert.AreEqual(_facilityNumber, inventoryWeek.FacilityNumber);
            Assert.AreEqual(_weekEndDate, inventoryWeek.WeekEndDate);
         }

         [Test]
         public void GetInventoryWeekReturnsWithFacilityInventoryTest()
         {
            var inventoryWeek = CreateSUT().GetInventoryWeek(_facilityNumber, _weekEndDate);
            Assert.IsTrue(inventoryWeek.FacilityInventory.Count() > 0);
         }

         private IInventoryRepository CreateSUT()
         {
            return new InventoryRepositoryStub();
         }
      }
   }
}